package main

import (
	"fmt"
	"math"
)

type calc interface {
	Calc() string
}

type areaError struct {
	radius float64
	msg    string
}
func (r *areaError) Calc() string {
	return fmt.Sprintf("圆的半径是：%.2f,%s", r.radius, r.msg)
}

func circleArea(radius float64) (float64, calc) {
	if radius <= 0 {
		return 0, &areaError{
			radius: radius,
			msg:    "长度是非法的",
		}
	}
	return math.Pi * radius * radius, &areaError{
		radius: radius,
		msg:    "长度是合法的",
	}
}

func main() {
	area, calc := circleArea(12)
	fmt.Printf("%s,圆的面积是：%.2f \n", calc.Calc(), area)
}
